import { takeEvery, put } from "redux-saga/effects"
import axios from "axios"

axios.defaults.baseURL = "http://strapi.roch.top:11337"

function* loadWebsites () {
  let { data } = yield axios.get("/websites")
  yield put({ type: "loadWebsitesSuccess", payload: data })
}


function* addWebsite ({ website }) {
  let { data } = yield axios.post("/websites", website)
  yield put({ type: "add", payload: data })
}


export default function* websiteSaga () {
  yield takeEvery("loadWebsites", loadWebsites)
  yield takeEvery("addWebsite", addWebsite)
}
